package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author hm
 * @package com.sky.mapper
 * @date Created in 2024/11/22 22:37
 */
@Mapper
public interface OrdersMapper {

    void insert(Orders orders);

    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> selectByStatusAndTime(Integer status, LocalDateTime orderTime);

    void update(Orders order);

//    @Select("select * from orders where number=#{orderNumber} and user_id=#{userId}")
//    Orders getByNumberAndUserId(String orderNumber, Long userId);

    @Select("select * from orders where number=#{orderNumber}")
    Orders getByNumberAndUserId(String orderNumber);

    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);

    Double getSumByMap(Map map);

    /**
     * 分页条件查询并按下单时间排序
     * @param ordersPageQueryDTO
     */
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
}
